package com.im.partchat.mvp.model.friend;

import com.im.partchat.bean.FriendApply;
import com.im.partchat.bean.reponsed.BaseResponse;
import com.im.partchat.bean.request.FriendAddRequest;
import com.im.partchat.bean.request.FriendConfirmRequest;
import com.im.partchat.bean.request.FriendDeleteRequest;
import com.im.partchat.bean.request.FriendListRequest;
import com.im.partchat.bean.request.RequestBean;
import com.im.partchat.http.service.FriendService;

import java.util.List;

import io.reactivex.Observable;

/**
 * Created by hhz on 2017/7/3.
 */
public class FriendModelImpl implements FriendModel {
    @Override
    public Observable<BaseResponse<Object>> friendApplyAdd(String userId, String friendId) {
        RequestBean<FriendAddRequest> requestBean = new RequestBean<>();
        requestBean.setData(new FriendAddRequest(userId, friendId));
        return FriendService.friendApplyAdd(requestBean);
    }

    @Override
    public Observable<BaseResponse<Object>> friendApplyConfirm(String applyId, boolean result) {
        RequestBean<FriendConfirmRequest> requestBean = new RequestBean<>();
        requestBean.setData(new FriendConfirmRequest(applyId, result));
        return FriendService.friendApplyConfirm(requestBean);
    }

    @Override
    public Observable<BaseResponse<Object>> friendDelete(String userId, String friendId) {
        RequestBean<FriendDeleteRequest> requestBean = new RequestBean<>();
        requestBean.setData(new FriendDeleteRequest(userId, friendId));
        return FriendService.friendDelete(requestBean);
    }

    @Override
    public Observable<BaseResponse<List<FriendApply>>> friendApplyList(String userId) {
        RequestBean<FriendListRequest> requestBean = new RequestBean<>();
        requestBean.setData(new FriendListRequest(userId));
        return FriendService.friendApplyList(requestBean);
    }
}
